**Code to generate the results in Table 2

*Census: 1991 
clear
cd "/Users/lucienetorresdemellopereira/Documents/EPGE_Mac/Doutorado/Censo/Censo91"
use Census_91.dta

*Generating location variables
gen urban = [sit_setor_C == 1]
gen rural = [sit_setor_C == 0]
gen slum = [sit_setor_C == 1 & subnormal==1]
gen city = [sit_setor_C == 1 & subnormal==0]

*Computing the mean of rents for rural areas in Brazil
*average
mean aluguel if (cond_ocup==2 & tot_dorm>0 & rural==1) [iweight=peso_dom]
*#bedrooms=1
mean aluguel if (cond_ocup==2 & tot_dorm==1 & rural==1) [iweight=peso_dom]
*#bedrooms=2
mean aluguel if (cond_ocup==2 & tot_dorm==2 & rural==1) [iweight=peso_dom]
*#bedrooms=3
mean aluguel if (cond_ocup==2 & tot_dorm==3 & rural==1) [iweight=peso_dom]

*Computing the mean of rents for rural areas in Brazil
*average
mean aluguel if (cond_ocup==2 & tot_dorm>0 & urban==1) [iweight=peso_dom]
*#bedrooms=1
mean aluguel if (cond_ocup==2 & tot_dorm==1 & urban==1) [iweight=peso_dom]
*#bedrooms=2
mean aluguel if (cond_ocup==2 & tot_dorm==2 & urban==1) [iweight=peso_dom]
*#bedrooms=3
mean aluguel if (cond_ocup==2 & tot_dorm==3 & urban==1) [iweight=peso_dom]


*Census: 1991 RJ & SP
clear
cd "/Users/lucienetorresdemellopereira/Documents/EPGE_Mac/Doutorado/Censo/Censo91"
use Census_91_rents_RJ_SP.dta

*Generating location variables
gen urban = [sit_setor_C == 1]
gen rural = [sit_setor_C == 0]
gen slum = [sit_setor_C == 1 & subnormal==1]
gen city = [sit_setor_C == 1 & subnormal==0]

*Computing the mean of rents for rural areas in Rio de Janeiro
*average
mean aluguel if (cond_ocup==2 & tot_dorm>0 & rural==1 & UF==33) [iweight=peso_dom]
*#bedrooms=1
mean aluguel if (cond_ocup==2 & tot_dorm==1 & rural==1 & UF==33) [iweight=peso_dom]
*#bedrooms=2
mean aluguel if (cond_ocup==2 & tot_dorm==2 & rural==1 & UF==33) [iweight=peso_dom]
*#bedrooms=3
mean aluguel if (cond_ocup==2 & tot_dorm==3 & rural==1 & UF==33) [iweight=peso_dom]

*Computing the mean of rents for formal city in the city of Rio de Janeiro
*average
mean aluguel if (cond_ocup==2 & tot_dorm>0 & city==1 & munic==330455) [iweight=peso_dom]
*#bedrooms=1
mean aluguel if (cond_ocup==2 & tot_dorm==1 & city==1 & munic==330455) [iweight=peso_dom]
*#bedrooms=2
mean aluguel if (cond_ocup==2 & tot_dorm==2 & city==1 & munic==330455) [iweight=peso_dom]
*#bedrooms=3
mean aluguel if (cond_ocup==2 & tot_dorm==3 & city==1 & munic==330455) [iweight=peso_dom]

*Computing the mean of rents for slums in the city of Rio de Janeiro
*average
mean aluguel if (cond_ocup==2 & tot_dorm>0 & slum==1 & munic==330455) [iweight=peso_dom]
*#bedrooms=1
mean aluguel if (cond_ocup==2 & tot_dorm==1 & slum==1 & munic==330455) [iweight=peso_dom]
*#bedrooms=2
mean aluguel if (cond_ocup==2 & tot_dorm==2 & slum==1 & munic==330455) [iweight=peso_dom]
*#bedrooms=3
mean aluguel if (cond_ocup==2 & tot_dorm==3 & slum==1 & munic==330455) [iweight=peso_dom]


*Computing the mean of rents for rural areas in São Paulo
*average
mean aluguel if (cond_ocup==2 & tot_dorm>0 & rural==1 & UF==35) [iweight=peso_dom]
*#bedrooms=1
mean aluguel if (cond_ocup==2 & tot_dorm==1 & rural==1 & UF==35) [iweight=peso_dom]
*#bedrooms=2
mean aluguel if (cond_ocup==2 & tot_dorm==2 & rural==1 & UF==35) [iweight=peso_dom]
*#bedrooms=3
mean aluguel if (cond_ocup==2 & tot_dorm==3 & rural==1 & UF==35) [iweight=peso_dom]

*Computing the mean of rents for formal city in the city of São Paulo
*average
mean aluguel if (cond_ocup==2 & tot_dorm>0 & city==1 & munic==355030) [iweight=peso_dom]
*#bedrooms=1
mean aluguel if (cond_ocup==2 & tot_dorm==1 & city==1 & munic==355030) [iweight=peso_dom]
*#bedrooms=2
mean aluguel if (cond_ocup==2 & tot_dorm==2 & city==1 & munic==355030) [iweight=peso_dom]
*#bedrooms=3
mean aluguel if (cond_ocup==2 & tot_dorm==3 & city==1 & munic==355030) [iweight=peso_dom]


*Computing the mean of rents for slums in the city of São Paulo
*average
mean aluguel if (cond_ocup==2 & tot_dorm>0 & slum==1 & munic==355030) [iweight=peso_dom]
*#bedrooms=1
mean aluguel if (cond_ocup==2 & tot_dorm==1 & slum==1 & munic==355030) [iweight=peso_dom]
*#bedrooms=2
mean aluguel if (cond_ocup==2 & tot_dorm==2 & slum==1 & munic==355030) [iweight=peso_dom]
*#bedrooms=3
mean aluguel if (cond_ocup==2 & tot_dorm==3 & slum==1 & munic==355030) [iweight=peso_dom]
